import React, { Component } from "react";
import State from "./state";
import { Route, NavLink } from "react-router-dom";

const obj = {
  name: "周三",
  age: 18,
};
export default class C extends Component {
  handleFetch = async () => {
    try {
      const response = await fetch("hhh");
      const data = await response.json();
      console.log(data);
    } catch (error) {
      console.log(error);
    }
  };
  render() {
    return (
      <div>
        <h3>State传参</h3>
        <hr />
        <NavLink
          to={{
            pathname: "/home/c/state",
            state: { name: obj.name, age: obj.age },
          }}
        >
          State
        </NavLink>
        <hr />
        <Route path="/home/c/state" component={State}></Route>
        {/* fetch发送请求 */}
        <button onClick={this.handleFetch}>fetch</button>
      </div>
    );
  }
}
